package com.ss.android.f.b.a.a;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.text.TextUtils;

import com.bytedance.common.utility.Logger;

import java.util.concurrent.ConcurrentHashMap;

public final class AccountCacheHelper extends c {
    final AccountManager a;
    public Account b;
    public final ConcurrentHashMap c;

    public AccountCacheHelper(Context arg2) {
        this.c = new ConcurrentHashMap();
        this.a = AccountManager.get(arg2);
    }

    protected final String a(String arg6) {
        String v1_1;
        String v0 = null;
        if (this.b != null) {
            try {
                v1_1 = this.a.getUserData(this.b, arg6);
                if (Logger.debug()) {
                    Logger.d("AccountCacheHelper", "get cached string : key = " + arg6 + ",value = " + v1_1);
                }
            } catch (Throwable v1) {
                if (Logger.debug()) {
                    Logger.ee("get string error,please fix it : ");
                }

                v1.printStackTrace();
                return v0;
            }

            v0 = v1_1;
        }

        return v0;
    }

    protected final void a(String arg4, String arg5) {
        if (this.b == null) {
            this.c.put(arg4, arg5);
            return;
        }

        if (arg4 != null && arg5 != null) {
            try {
                if (Logger.debug()) {
                    Logger.d("AccountCacheHelper", "cache string : key = " + arg4 + ",value = " + arg5);
                }

                this.a.setUserData(this.b, arg4, arg5);
            } catch (Throwable v0) {
                if (Logger.debug()) {
                    Logger.ee("save string error,please fix it : ");
                }

                v0.printStackTrace();
            }
        }
    }

    protected final void a(String arg2, String[] arg3) {
        if (arg3 != null) {
            this.a(arg2, TextUtils.join("\n", ((Object[]) arg3)));
        }
    }

    protected final String[] b(String arg3) {
        String v0 = this.a(arg3);
        String[] v0_1 = TextUtils.isEmpty(((CharSequence) v0)) ? null : v0.split("\n");
        return v0_1;
    }
}

